import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import VueRouter from 'unplugin-vue-router/vite'
import Components from 'unplugin-vue-components/vite'
import path from 'node:path'
import UnoCSS from 'unocss/vite'
import { templateCompilerOptions } from '@tresjs/core'
import glsl from 'vite-plugin-glsl'

// https://vitejs.dev/config/
export default defineConfig({
  base: './',
  build: {
    target: 'esnext',
    sourcemap: false,
    rollupOptions: {
      output: {
        sourcemapFileNames: 'sourcemap/[name]-[chunkhash].js.map'
      }
    }
  },
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "src"),
      "#": path.resolve(__dirname, "types")
    }
  },
  plugins: [
    VueRouter({
      dts: 'types/typed-router.d.ts',
      exclude: ['**/_*'],
    }),
    vue({
      ...templateCompilerOptions
    }),
    glsl({
      root: '/src/glsl'
    }),
    UnoCSS(),
    Components({
      resolvers: [],
      dts: 'types/components.d.ts'
    })
  ],
})
